<template>
  <div class="new-disc">
    <home-nav title="新碟上架" @jumpPlaylist="jumpPlaylist"/>
    <song-list-layout
        :playlists="albumsList"
        :module="2"
        @jumpPlayListDetails="jumpPlayListDetails"
        @play="play"
    />
  </div>
</template>

<script setup>
import HomeNav from '@/components/HomeNav/index.vue'
import { getAlbumNewest } from "@/api/home/index"
import { useRouter } from "vue-router"
import {ref} from "vue"
import SongListLayout from '@/components/SongListLayout/index.vue'
import {useStore} from "@/store/index"

const albumsList = ref([])
const router = useRouter()
const store = useStore()

getAlbumNewest().then(res => {
  const { albums, code } = res
  if(Number(code) === 200) {
    albumsList.value = albums.slice(0, 8)
  }
  // console.log(res)
})
// 点击更多跳转
const jumpPlaylist = () => {
  router.push({
    path: '/discover/new-disc'
  })
}
// 点击卡片跳转
const jumpPlayListDetails = (id) => {
  router.push({
    path: '/collection-detail',
    query: {
      id
    }
  })
}
// 点击播放
const play = (id) => {
  // 获取数据歌单数据
  store.getPlaylistDetail(id)
}
</script>

<style scoped>

</style>
